package corej.course.gui.eventmonitor;

//�¼�Դ����
public class Girl {
    String name;

    EmotionListener bf;

    public Girl(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    // ��b��Ȩ��ϵ
    public void addEmotionListener(EmotionListener bf) {
        this.bf = bf;
        System.out.println(name + " said: �����ڼ޳�ȥ�ˡ�");
    }

    // �����Ȩ��ϵ
    public void removeEmotionListener(EmotionListener bf) {
        if (this.bf == bf) {
            System.out.println(name + " said: �뿪���ҿ���ô��");
            this.bf = null;
        }
    }

    public void fire() {
        EmotionEvent e = new EmotionEvent(this);
        for (int day = 1; day <= 10; day++) {
            /*
                * ---------------�¼�ģ�͵Ĺؼ�----------------- ��ν�¼�Դ���¼����������¼�����
                * �����¼�Դ���¼�������Ϊ��������¼����������Ӧ���� bf.whatCanIdoWhenGirlHappy(e);
                * bf.whatCanIdoWhenGirlSad(e);
                * ---------------�¼�ģ�͵Ĺؼ�-----------------
                */
            System.out.println("Day " + day);
            if (day % 2 == 1)
                bf.whatCanIdoWhenGirlHappy(e);
            else
                bf.whatCanIdoWhenGirlSad(e);
        }
    }

}
